﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title>获取数组长度</title>
</head>
<body>
    <p id="demo">创建一个数组，并显示数组元素个数。</p>
    <button onclick="myFunction()">获取长度</button>
    <script>
        function myFunction() {
            let fruits = ["Banana", "Orange", "Apple", "Mango"];
            let x = document.getElementById("demo");
            x.innerHTML = fruits.length;
        }
    </script>
</body>
